<!DOCTYPE html>
<html>

<head>
    <title>学生列表</title>
    <style>
        body {
            font-family: Arial;
            padding: 20px;
        }
        
        table {
            border-collapse: collapse;
            width: 300px;
        }
        
        th,
        td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        
        th {
            background-color: #f2f2f2;
        }
    </style>
</head>

<body>
    <h2>学生信息（PDO查询结果）</h2>
    <?php if ($data): ?>
    <table>
        <tr>
            <th>ID</th>
            <th>姓名</th>
        </tr>
        <?php foreach ($data as $row): ?>
        <tr>
            <td>
                <?= $row['id'] ?>
            </td>
            <td>
                <?= $row['name'] ?>
            </td>
        </tr>
        <?php endforeach; ?>
    </table>
    <?php else: ?>
    <p>暂无数据</p>
    <?php endif; ?>
</body>

</html>